import 'package:flutter/material.dart';

class RefreshDemp extends StatefulWidget {
  @override
  _RefreshDempState createState() => _RefreshDempState();
}

class _RefreshDempState extends State<RefreshDemp> {
  List<String> titles = List.generate(20, (index){
    return 'title_$index';
  });
  @override
  Widget build(BuildContext context) {
    return Container(
      child: RefreshIndicator(
        displacement: 20,
        child: ListView.builder(itemBuilder: (context,index){
            return Text(titles[index]);
        },itemCount: titles.length,),
        onRefresh: _refreshData,

      ),
    );
  }

  Future<Null> _refreshData() async{
    await Future.delayed(Duration(seconds: 3),(){
      print('refreshData');
    });
  }
}
